package com.ruoyi.project.hcy.administrations.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.hcy.administrations.domain.Invite;
import com.ruoyi.project.hcy.administrations.domain.Posting;
import com.ruoyi.project.hcy.administrations.service.IPostingService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ClassName ApproveController
 * @Author 金刚芭比
 * @Date 2020/9/17 10:55
 * @Version 1.0
 */
@Controller
@RequestMapping("/hcy/posting")
public class PostingController extends BaseController {

    private String prefix="hcy/administrations";

    @Autowired
    private IPostingService postingService;

    @GetMapping
    public String toposting(){
        return prefix + "/posting";
    }

    @RequiresPermissions("hcy:posting:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo postinglist() {
        startPage();
        List<Posting> list = postingService.selectPostingAll("待审批..");
        return getDataTable(list);
    }


    @GetMapping("/add")
    public String toaddposting(){
        return  prefix + "/addposting";
    }
    @RequiresPermissions("hcy:posting:add")
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addPosting(@Validated Posting posting)
    {
        return toAjax(postingService.insertPosting(posting));
    }

}
